#include "Common.h"

initSing(LuaHookMgr);

void LuaHookMgr::RegisterHook(ui32 hooktype, string funcname)
{
	m_functions[hooktype].push_back(funcname);
}

bool LuaHookMgr::OnAccountLogin(const char* accname, const char* ip)
{
	return true;
}

void LuaHookMgr::OnAreaChanged(ui32 areaid, Player* plr)
{
	list<string>::iterator itr = m_functions[ON_AREA_CHANGED].begin();
	list<string>::iterator end = m_functions[ON_AREA_CHANGED].end();

	for( ; itr != end; ++itr)
	{
		try{
			LUAPlayer lup;
			lup.plr = plr;
			call_function<LUAPlayer>(state, (*itr).c_str(), lup, areaid);
		}
		catch(luabind::error& err)
		{
			Log->Error("LUA", "Error: %s", err.what());
		}
	}
}

void LuaHookMgr::OnCharDelete(Player* plr)
{
}

void LuaHookMgr::OnCharLogin(Player* plr)
{
}

void LuaHookMgr::OnNewChar(Player* plr)
{
}